package me.numark.view;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

import butterknife.Bind;
import butterknife.ButterKnife;
import me.numark.R;
import me.numark.activities.ProfileActivity;
import me.numark.model.Like;
import me.numark.model.User;
import me.numark.utils.Global;

/**
 * Created by Evan on 15/7/24.
 */
public class UserGridViewHolder extends BaseViewHolder implements View.OnClickListener {
    @Bind(R.id.avatar)
    public CircleImageView avatar;

    public static final int STYLE_NONE = 0;
    public static final int STYLE_NORMAL = 1;
    Context mContext;

    public UserGridViewHolder(View itemView, Object parent, int style) {
        super(itemView, parent);
        if (style == STYLE_NONE)
            return;
        mContext = itemView.getContext();
        ButterKnife.bind(this, itemView);
//        addOnClickListener(avatar);
        addOnClickListener(itemView);
        avatar.setBorderColor(Global.avatarColor);
        avatar.setBorderWidth(2);
    }

    private Like mLike;

    public void bindData(Like like) {
        mLike = like;
        Picasso.with(mContext).load(mLike.user.pic).into(avatar);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.user_grid_view:
            case R.id.avatar: {
                Intent intent = new Intent(mContext, ProfileActivity.class);
                intent.putExtra(ProfileActivity.EXTRA_UID, mLike.user.uid);
                mContext.startActivity(intent);
            }
            break;
        }
    }
}
